home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmMain
- Caption = "Demo VSFlexData - Linked List"
- ClientHeight = 1350
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 1350
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.Label Label1
- Caption = "Please follow along documented code and look at the immediate pane for results."
- Height = 855
- Left = 360
- TabIndex = 0
- Top = 240
- Width = 3495
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' Demonsration of VSFlexData object
- ' Copyright
- 1998, VocalSoft Communications
- ' All rights reserved.
- Option Explicit
- ' The purpose of this project is to demostrate how to
- ' create a doubly linked list with a few lines of code.
- ' The created list is flexible enough to store any
- ' kind of data.
- ' The actual code for the linked list is in List.BAS.
- Private Sub Form_Load()
- Dim x As VSFlexData: Set x = New VSFlexData
- ' Initialize the list
- InitList
- ' Demonstrate the list with one kind of data:
- ' This particular data consists of heights and
- ' weights.
- DemoMeasures
- ' Initialize the list again
- InitList
- ' Now use the same code to demonstrate how we can
- ' use a different kind of data with the same list
- ' code. This particular data consists of Names,
- ' Addresses, and Phone Numbers.
- DemoPhonebook
- End Sub
- Private Sub InitList()
- ' In case it's already set
- Set g_vsfList = Nothing
- ' Instantiate the object
- Set g_vsfList = New VSFlexData
- ' Setup the object of dynamic array type
- g_vsfList.SetArray
- End Sub
- Private Sub DemoMeasures()
- ' Demonstrates how the list code is used to store and
- ' maintain heights and weights
- ' Create a new map
- Dim vsfData As VSFlexData
- Set vsfData = New VSFlexData
- vsfData.SetMap
- ' Setup the map with height and
- ' weight
- vsfData!Height = 4.1
- vsfData!Weight = 55
- ' Add map to the list
- InsertNode vsfData
- '... REPEAT...
- vsfData!Height = 5.3
- vsfData!Weight = 75
- InsertNode vsfData
- '... REPEAT...
- vsfData!Height = 6.2
- vsfData!Weight = 105
- InsertNode vsfData
- ' Traverse the list and
- ' print data in the debug window or
- ' immediate pane
- TraversePrint
- Debug.Print
- End Sub
- Private Sub DemoPhonebook()
- ' Demonstrates how the same list code is used to
- ' store and maintain a different kind
- ' of data: phonebook entries
- ' Create a new map
- Dim vsfData As VSFlexData
- Set vsfData = New VSFlexData
- vsfData.SetMap
- ' Setup the map with phonebook
- ' entries
- vsfData!Name = "Bill Gates"
- vsfData!Address = "10 Microsoft Drive"
- vsfData!Phone = 9005551212#
- ' Add map to the list
- InsertNode vsfData
- ' ...REPEAT...
- vsfData!Name = "Ross Perot"
- vsfData!Address = "15 Texas Ave."
- vsfData!Phone = 8005551212#
- InsertNode vsfData
- ' ...REPEAT...
- vsfData!Name = "Tom Cruise"
- vsfData!Address = "1 Hollywood Circle"
- vsfData!Phone = 8885551212#
- InsertNode vsfData
- ' Traverse the list and
- ' print data in the debug window or
- ' immediate pane
- TraversePrint
- Debug.Print
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- ' Clear the object
- g_vsfList.RemoveAll
- Set g_vsfList = Nothing
- End Sub
-